package com.example.backspring.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.backspring.entity.Goal;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.Delete;

import java.util.List;

@Mapper
public interface GoalMapper extends BaseMapper<Goal> {
    @Insert("insert into goal (id,sj,nr,pod,jtbz,khl,ksx,xgx,ysx) values (#{id},#{sj},#{nr},#{pod},#{jtbz},#{khl},#{ksx},#{xgx},#{ysx} );")
    int addGoal(int id, String sj, String nr, int pod, String jtbz, String khl, String ksx, String xgx, String ysx);

    @Update("update goal set pod =1 where id=#{id}")
    int updateGoalById(int id);

    @Update("update goal set jtbz =#{nr} where id=#{id}")
    int updateA(int id, String nr);

    @Update("update goal set khl =#{nr} where id=#{id}")
    int updateB(int id, String nr);

    @Update("update goal set ksx =#{nr} where id=#{id}")
    int updateC(int id, String nr);

    @Update("update goal set xgx =#{nr} where id=#{id}")
    int updateD(int id, String nr);

    @Update("update goal set ysx =#{nr} where id=#{id}")
    int updateE(int id, String nr);

    @Update("update goal set nr =#{nr} where id=#{id}")
    int updateNR(int id, String nr);


    @Select("select * from goal  ORDER BY pod  DESC ")
    List<Goal> getGoals();

    @Delete("delete from goal where id = #{id}")
    int deleteGoalById(int id);
}
